1 left.jsp代码修改
d.add('0105','01','订单管理');d.add('010501','0105','订单管理','${pageContext.request.contextPath}/admin?method=findAllOrders','','mainFrame');
2 AdminServlet代码findAllOrders
// 5 获得所有订单 findAllOrderspublic void findAllOrders(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 获得所有的订单信息---ListAdminService service = new AdminService(); List orderList = null; try { orderList = service.findAllOrdersList(); } catch (SQLException e) { e.printStackTrace(); } request.setAttribute("orderList", orderList); request.getRequestDispatcher("/admin/order/list.jsp").forward(request, response);}
3 AdminService代码
// 获取所有订单public ListfindAllOrdersList() throws SQLException { AdminDao dao = new AdminDao(); return dao.findAllOrdersList(); }
4 AdminDao代码
// 获取所有的订单信息public ListfindAllOrdersList() throws SQLException { QueryRunner qr = new QueryRunner(C3P0Utils.getDataSource()); String sql ="select * from orders"; return qr.query(sql, new BeanListHandler (Order.class));}
5 admin/oder/list.jsp代码
<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>